package com.zed.api.common.resource;


import java.io.File;

/**
 * 基于maven编译输出target/classes目录的扫描器
 *
 * @author Zed
 */
class TargetClassesResourceScanner extends FileSystemResourceScanner {

    private static final String CLASSES = "classes";
    private static final String TEST_CLASSES = "test-classes";

    /**
     * 构造方法
     */
    public TargetClassesResourceScanner() {

    }

    @Override
    protected File getSupportFile(File file) {
        if (file == null) return null;

        if (file.getName().equals(CLASSES)) {
            return file;
        }

        if (file.getName().equals(TEST_CLASSES)) {
            return file;
        }

        return getSupportFile(file.getParentFile());
    }

    @Override
    public String toString() {
        return "TargetClassesResourceScanner";
    }

}
